/**
 * Created by Vit on 24.11.2014.
 */
var slideIndex = 0;
var previousAction = "";

function goLeft(){
    if(slideIndex == 0) {
        slideIndex = 2;
        toggleMoveLabel();
    } else if (slideIndex == 1) {
        slideIndex--;
        toggleMoveLabel();
    } else {
        slideIndex--;
    }
    previousAction = "SlideLeft";
    $.fn.fullpage.moveSlideLeft();
}

function goRight(){
    if(slideIndex == 2) {
        slideIndex = 0;
        toggleMoveLabel();
    } else if (slideIndex == 0) {
        slideIndex++;
        toggleMoveLabel();
    } else {
        slideIndex++;
    }
    previousAction = "SlideRight";
    $.fn.fullpage.moveSlideRight();
}

function toggleMoveLabel(){
    if ($('#moveLabel').text() == "BACK") {
        $('#moveLabel').text('NEXT');
    } else {
        $('#moveLabel').text('BACK');
    }

}

function goBack(){
    if (previousAction == "SlideRight")
        goLeft();
    else
        goRight();
}

function showLoading(){
    if (window.location.href.indexOf("Portfolio") > -1){

        $('#loading_wrap').show();
        var i;
        for (i=0;i<10;i++){
            setTimeout(function() {
                $("#loading_wrap").remove();
            }, 3000);
        }

        //$(window).on('hashchange',null);
    }
}

